function createfigure(X1, YMatrix1, YMatrix2, YMatrix3, YMatrix4, ...
                    YMatrix5, YMatrix6, YMatrix7, YMatrix8);
%createfigure(X1, YMatrix1, YMatrix2, YMatrix3, YMatrix4, ...
%                    YMatrix5, YMatrix6, YMatrix7, YMatrix8);
%  X1:  vector of plot x data
%  YMATRIX1:  matrix of plot y data
%  YMATRIX2:  matrix of plot y data
%  YMATRIX3:  matrix of plot y data
%  YMATRIX4:  matrix of plot y data
%  YMATRIX5:  matrix of plot y data
%  YMATRIX6:  matrix of plot y data
%  YMATRIX7:  matrix of plot y data
%  YMATRIX8:  matrix of plot y data

%  Auto-generated by MATLAB on 07-Dec-2022 19:58:00

% Create figure
figure1 = figure('WindowState','maximized');

%% fz plots
% Create subplot
subplot1 = subplot(4,2,1,'Parent',figure1);
hold(subplot1,'on');

% Create multiple line objects using matrix input to plot
plot1 = plot(X1,YMatrix1,'Parent',subplot1,'LineWidth',2);
set(plot1(1),'DisplayName','MPC');
set(plot1(2),'DisplayName','ideal');

% Create ylabel
ylabel('$f_1$ (N)','FontWeight','bold','FontName','Arial','Interpreter','latex');

box(subplot1,'on');
hold(subplot1,'off');
% Set the remaining axes properties
set(subplot1,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend1 = legend(subplot1,'show');
set(legend1,'EdgeColor',[0 0 0]);
ylim([0,40])

% Create subplot
subplot2 = subplot(4,2,3,'Parent',figure1);
hold(subplot2,'on');

% Create multiple line objects using matrix input to plot
plot2 = plot(X1,YMatrix2,'Parent',subplot2,'LineWidth',2);
set(plot2(1),'DisplayName','MPC');
set(plot2(2),'DisplayName','ideal');

% Create ylabel
ylabel('$f_2$ (N)','FontWeight','bold','FontName','Arial', 'Interpreter','latex');
ylim([0,40])

box(subplot2,'on');
hold(subplot2,'off');
% Set the remaining axes properties
set(subplot2,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend(subplot2,'show');

% Create subplot
subplot3 = subplot(4,2,5,'Parent',figure1);
hold(subplot3,'on');

% Create multiple line objects using matrix input to plot
plot3 = plot(X1,YMatrix3,'Parent',subplot3,'LineWidth',2);
set(plot3(1),'DisplayName','MPC');
set(plot3(2),'DisplayName','ideal');

% Create ylabel
ylabel('$f_3$ (N)','FontWeight','bold','FontName','Arial','Interpreter','latex');

box(subplot3,'on');
hold(subplot3,'off');
% Set the remaining axes properties
set(subplot3,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend(subplot3,'show');
ylim([0,40])

% Create subplot
subplot4 = subplot(4,2,7,'Parent',figure1);
hold(subplot4,'on');

% Create multiple line objects using matrix input to plot
plot4 = plot(X1,YMatrix4,'Parent',subplot4,'LineWidth',2);
set(plot4(1),'DisplayName','MPC');
set(plot4(2),'DisplayName','ideal');

% Create ylabel
ylabel('$f_4$ (N)','FontWeight','bold','FontName','Arial','Interpreter','latex');
ylim([0,40])

% Create xlabel
xlabel('time (s)','FontWeight','bold','FontSize',12);

box(subplot4,'on');
hold(subplot4,'off');
% Set the remaining axes properties
set(subplot4,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend2 = legend(subplot4,'show');
set(legend2,...
    'Position',[0.415277778274483 0.218421644884768 0.0432291661699611 0.0399792305158059]);

% Create axes
axes('Parent',figure1);
axis off

% % Create xlabel
% xlabel('time (s)','FontWeight','bold','FontSize',12,'FontName','Arial',...
%     'Visible','on');


%% state plots
% Create subplot
subplot5 = subplot(4,2,2);
hold(subplot5,'on');

% Create multiple line objects using matrix input to plot
plot5 = plot(X1,YMatrix5,'LineWidth',2);
set(plot5(1),'DisplayName','$p_x$');
set(plot5(2),'DisplayName','$p_y$');
set(plot5(3),'DisplayName','$p_{x,ref}$',...
    'Color',[0.494117647058824 0.184313725490196 0.556862745098039]);
set(plot5(4),'SeriesIndex',5,'DisplayName','$p_{y,ref}$','LineStyle','--',...
    'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]);

% Create ylabel
ylabel('$\mathbf{p}$ (m)','HorizontalAlignment','center',...
    'FontWeight','bold',...
    'FontName','Arial',...
    'Interpreter','latex');

box(subplot5,'on');
hold(subplot5,'off');
% Set the remaining axes properties
set(subplot5,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend5 = legend(subplot5,'show');
set(legend5,'Orientation','horizontal','Location','north',...
    'Interpreter','latex',...
    'EdgeColor',[0 0 0]);
ylim(subplot5,[-0.2 0.7]);

% Create subplot
subplot6 = subplot(4,2,4);
hold(subplot6,'on');

% Create multiple line objects using matrix input to plot
plot6 = plot(X1,YMatrix6,'LineWidth',2);
set(plot6(1),'DisplayName','$v_x$');
set(plot6(2),'DisplayName','$v_y$');
set(plot6(3),'DisplayName','$v_{x,ref}$',...
    'Color',[0.494117647058824 0.184313725490196 0.556862745098039]);
set(plot6(4),'DisplayName','$v_{y,ref}$','LineStyle','--',...
    'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]);

% Create ylabel
ylabel('$\mathbf{v}$ (m/s)','HorizontalAlignment','center',...
    'FontWeight','bold',...
    'FontName','Arial',...
    'Interpreter','latex');

% Uncomment the following line to preserve the Y-limits of the axes
ylim(subplot6,[-0.2 0.8]);
box(subplot6,'on');
hold(subplot6,'off');
% Set the remaining axes properties
set(subplot6,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend6 = legend(subplot6,'show');
set(legend6,...
    'Location','north',...
    'Orientation','horizontal',...
    'Interpreter','latex');

% Create subplot
subplot7 = subplot(4,2,6);
hold(subplot7,'on');

% Create multiple line objects using matrix input to plot
plot7 = plot(X1,YMatrix7,'LineWidth',2);
set(plot7(1),'DisplayName','$\phi$');
set(plot7(2),'DisplayName','$\theta$');
set(plot7(3),'DisplayName','$\psi$');
set(plot7(4),'DisplayName','$\psi_{ref}$','LineStyle','--',...
    'Color',[0.494117647058824 0.184313725490196 0.556862745098039]);

% Create ylabel
ylabel('$\mathbf{\Theta}$ (rad)','HorizontalAlignment','center',...
    'FontWeight','bold',...
    'FontName','Arial',...
    'Interpreter','latex');

% Uncomment the following line to preserve the Y-limits of the axes
ylim(subplot7,[-0.155368462626757 1.1]);
box(subplot7,'on');
hold(subplot7,'off');
% Set the remaining axes properties
set(subplot7,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend7 = legend(subplot7,'show');
set(legend7,'Orientation','horizontal','Location','north',...
    'Interpreter','latex');

% Create subplot
subplot8 = subplot(4,2,8);
hold(subplot8,'on');

% Create multiple line objects using matrix input to plot
plot8 = plot(X1,YMatrix8,'LineWidth',2);
set(plot8(1),'DisplayName','$\omega_\phi$');
set(plot8(2),'DisplayName','$\omega_\theta$');
set(plot8(3),'DisplayName','$\omega_\psi$');
set(plot8(4),'DisplayName','$\omega_{\phi,ref}$','LineStyle','--',...
    'Color',[0.494117647058824 0.184313725490196 0.556862745098039]);

% Create ylabel
ylabel('$\mathbf{\omega}$ (m/s)','HorizontalAlignment','center',...,
    'FontWeight','bold',...
    'FontName','Arial',...
    'Interpreter','latex');

% Create xlabel
xlabel('time (s)','FontWeight','bold','FontName','Arial');

% Uncomment the following line to preserve the Y-limits of the axes
ylim(subplot8,[-0.155368462626757  1.2]);
box(subplot8,'on');
hold(subplot8,'off');
% Set the remaining axes properties
set(subplot8,'FontName','Arial','FontSize',12,'LineWidth',1.5);
% Create legend
legend8 = legend(subplot8,'show');
set(legend8,...
    'Location','north',...
    'Orientation','horizontal',...
    'Interpreter','latex');

% Create axes
axes1 = axes;
axis off

% % Create xlabel
% xlabel('time (s)','FontWeight','bold','FontSize',12,'FontName','Arial',...
%     'Visible','on');

% Uncomment the following line to preserve the X-limits of the axes
 xlim(axes1,[0.0409946224906228 0.950085531581532]);
% Uncomment the following line to preserve the Y-limits of the axes
ylim(axes1,[0.0528881333091042 0.961979042400013]);

exportgraphics(figure1,'Figures/state.png','Resolution',300)


